package com.example.stlink.activitys;

import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.stlink.R;
import com.example.stlink.model.constants.ModelFieldConstants;
import com.example.stlink.utils.CommonUtils;
import com.example.stlink.utils.activityUtil.RegisterUtil;

/**
 * 学生端注册
 */
public class RegisterActivity extends AppCompatActivity {

    private TextView tvRgTitle;
    private ImageView ivRgUserImg;
    private EditText teaAccount;
    private EditText teaPwdFirst;
    private EditText teaPwdSecond;
    private Button btRegister;

    private Integer roleId;
    private Bundle bundle;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        initView();
    }

    /**
     * 初始化布局
     */
    private void initView(){
        //修改状态栏字体颜色
        CommonUtils.changeStatusBar(this);

        teaAccount = findViewById(R.id.id_rg);
        teaPwdFirst = findViewById(R.id.pwd_rg_first);
        teaPwdSecond = findViewById(R.id.pwd_rg_second);

        tvRgTitle = findViewById(R.id.tv_rg_title);
        ivRgUserImg = findViewById(R.id.rg_user_title_img);

        bundle = getIntent().getExtras();
        roleId = (Integer) bundle.get(ModelFieldConstants.ROLE_ID);

        if(roleId == 1){
            tvRgTitle.setText("教师端注册");
            ivRgUserImg.setImageResource(R.mipmap.teacher);
        }


        btRegister = findViewById(R.id.bt_register);

        setOnClickListener();
    }

    /**
     * 为按钮添加点击监听事件
     */
    private void setOnClickListener(){
        //为注册按钮添加点击监听事件
        RegisterUtil.userRegister(
                RegisterActivity.this,
                btRegister,
                teaAccount,
                teaPwdFirst,
                teaPwdSecond
        );
    }
}
